package com.base.system.config.swagger;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Value("${swagger.apiBasePth}")
    private String apiBasePth;
    @Value("${swagger.title}")
    private String title;
    @Value("${swagger.version}")
    private String version;

    @Bean
    Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage(apiBasePth))//需要api生成文件路径
                .paths(PathSelectors.any())//所有路径都生成文档
                .build().apiInfo(new ApiInfoBuilder()
                        .description("接口描述信息")
                        .title(title)
                        .contact(new Contact("木木","","1263237837@qq.com"))
                        .version(version)
                        .license("apache2.0")
                        .build()
                );//apiInfo是配置网站基本信息的

    }
}
